﻿<cfsilent>
	<cfscript>
	
		event.setArg("pageTitle", "教师门户 - 教学任务 - 体育项目课");

		stringAdvice = getProperty("serviceFactory").getBean("stringAdvice");
		taskProp = getProperty("serviceFactory").getBean("taskPropertyAdvice");
		dictAdvice = getProperty("serviceFactory").getBean("senateDictionaryAdvice");
		timeAdvice = getProperty("serviceFactory").getBean("datetimeAdvice");
		chooseProp = getProperty("serviceFactory").getBean("choosePropertyAdvice");

		taskId = event.getArg("TSK");
		
		targetArgs = structNew();
		structInsert(targetArgs, "TSK", taskId, true);
		structInsert(targetArgs, "TT", "T", true);

		/* 课程相关信息 */
		sql = "SELECT
					t_course.course_name, t_course.course_credit, 
					t_course.period, t_course.period_theory,
					t_institute.institute_name,
					t_course_catalog.cat_name,
					CASE WHEN t_course.intro IS NULL 
						THEN '-' ELSE  t_course.intro END intro,
					CASE WHEN t_course.reference_books IS NULL 
						THEN '-' ELSE t_course.reference_books END reference_books,
					CASE WHEN t_course.course_english IS NULL 
						THEN '-' ELSE t_course.course_english END course_english,
					t_course.cid, task_prop,
					t_course.course_code 
				FROM 
					t_sport_task a 
					INNER JOIN t_course ON t_course.cid = a.cid 
					INNER JOIN t_institute ON t_institute.institute_id = t_course.institute_id 
					INNER JOIN t_course_catalog ON t_course_catalog.cat_id = t_course.cat_id 
				WHERE 
					a.tsk_id = :taskId ";
					
		queryObj = new query( datasource=application.dnsSlave );
		
		queryObj.addParam( name="taskId", value=taskId, cfsqltype="cf_sql_varchar");
		
		rs_course = queryObj.execute( sql=sql ).getResult();
		
		/* 选课数据 */
		sql = "SELECT 
					t_student.stu_id, t_student.stu_name, 
					t_class.cls_name, t_class.grade,
					t_institute.institute_short,
					st, choose_time, retaking, choose_prop 
				FROM
					t_student_course a
					INNER JOIN t_student ON t_student.stu_id = a.stu_id 
					INNER JOIN t_class ON t_class.cls_id = t_student.cls_id 
					INNER JOIN t_subject ON t_subject.sbj_id = t_class.sbj_id
					INNER JOIN t_institute ON t_institute.institute_id = t_subject.institute_id
				WHERE
					a.task_id = :taskId 
				ORDER BY 
					a.stu_id";
					
		queryObj = new query( datasource=application.dnsSlave );
		
		queryObj.addParam( name="taskId", value=taskId, cfsqltype="cf_sql_varchar" );
		
		rs_chooser = queryObj.execute( sql=sql ).getResult();
		
		/* 教学任务属性 */
		//taskProp.parseProperty();
									
		/* 判断当前显示课表内容 */
		currentTab = event.getArg("TabID", "labCourse");

	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('courseTask')#</cfoutput>"><i class="mrs img btnPublish"></i><span class="uiButtonText">教学任务</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 application"></i><cfoutput>#rs_course.course_name#</cfoutput> - <cfoutput>#rs_course.cat_name#</cfoutput>
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="summary">
			
				<div class="UItab">
					<div class="tabLables">
						<span <cfif currentTab eq "labCourse">class="active"</cfif> id="labCourse" tabTarget="Course">课程介绍</span>
						<span <cfif currentTab eq "labStudent">class="active"</cfif> id="labStudent" tabTarget="Student">选课学生名单</span>
					</div>
				</div>
				
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					// -->
					//]]>
				</script>
				
				<div id="Course" class="tabContent">
					
					<div class="noticeBlock">
						<h3>《<cfoutput>#rs_course.course_name#</cfoutput>》 任课单位: <cfoutput>#rs_course.institute_name#</cfoutput></h3>
						<p>
							<span class="img icon16x16 message"></span>
							<cfif rs_course.course_code neq "-">课程号 <em><cfoutput>#rs_course.course_code#</cfoutput></em></cfif>
							总学时 <em><cfoutput>#rs_course.period#</cfoutput></em>, 其中理论学时 <em><cfoutput>#rs_course.period_theory#</cfoutput></em>. 课程总学分:<em><cfoutput>#numberFormat(rs_course.course_credit , '_.00')#</cfoutput></em>
							英文课程名 <em><cfif rs_course.course_english eq "-">None<cfelse><cfoutput>#rs_course.course_english#</cfoutput></cfif></em>
						</p>
					</div>
					
					<div id="courseInfo">

						<div class="noticeBlock">
							<h2>课程简介</h2>
							<div class="UIinlineEdit"><a href="javascript:courseEdit();" class="editTrigger">编辑</a></div>
							<cfif rs_course.intro neq "-">
								<cfoutput>#stringAdvice.XHTMLParagraphFormat(rs_course.intro)#</cfoutput>
								<cfelse>
								暂无
							</cfif>
						</div>
					
						<div class="noticeBlock">
							<h2>参考书籍</h2>
							<div class="UIinlineEdit"><a href="javascript:courseEdit();" class="editTrigger">编辑</a></div>
							<cfif rs_course.reference_books neq "-">
								<cfoutput>#stringAdvice.XHTMLParagraphFormat(rs_course.reference_books)#</cfoutput>
								<cfelse>
								暂无
							</cfif>
						</div>
					</div>
					
					<div id="courseEdit" class="hidden_elem">

						<form id="formUpdate" onSubmit="javascript:return processVerfiyForm('formUpdate');" class="formWrapper" method="post" action="<cfoutput>#buildURL('sportCourseUpdateDo')#</cfoutput>">
							
							<input type="hidden" name="CourseID" value="<cfoutput>#rs_course.cid#</cfoutput>" />
							<input type="hidden" name="TSK" value="<cfoutput>#taskId#</cfoutput>" />
							
							<div class="label">
								<b>英文名称</b>
								<input name="CourseEnglish" id="CourseEnglish" verification="required" type="text" class="typeText typeEnglish" maxlength="180" value="<cfif rs_course.course_english neq "-"><cfoutput>#stringAdvice.HTMLFormEncode( rs_course.course_english )#</cfoutput></cfif>" />
							</div>
						
							<div class="label">
								<b>课程介绍</b>
								<textarea name="Intro" id="Intro" verification="required"><cfif rs_course.intro neq "-"><cfoutput>#stringAdvice.HTMLFormEncode( rs_course.intro )#</cfoutput></cfif></textarea>
							</div>
						
							<div class="label">
								<b>参考书</b>
								<textarea name="ReferenceBooks" id="ReferenceBooks" verification="required"><cfif rs_course.reference_books neq "-"><cfoutput>#stringAdvice.HTMLFormEncode( rs_course.reference_books )#</cfoutput></cfif></textarea>
							</div>
						
							<hr/>
						
							<div class="lable">
								<input class="button" type="submit" value="保存" />
								<input onclick="courseEditCancel();" class="button4" type="button" value="取消" />
							</div>
							
						</form>

					</div>
					
					<script language="javascript" type="text/javascript">
						//<![CDATA[
						<!--
						function courseEdit() {
							
							$("div#courseInfo").addClass("hidden_elem");
							$("div#courseEdit").removeClass("hidden_elem");
							
							return void(0);
						}
						function courseEditCancel() {
							
							$("div#courseInfo").removeClass("hidden_elem");
							$("div#courseEdit").addClass("hidden_elem");
							
							return void(0);
						}
						// -->
						//]]>
					</script>
					
				</div>

				<div id="Student" class="tabContent">
					
					<div class="noticeBlock">
						<cfif rs_chooser.recordCount>
							<div class="operation">
								<a class="uiButton" target="_blank" href="<cfoutput>#buildURL('chooserPrint', targetArgs)#</cfoutput>"><i class="mrs img btnPrint"></i><span class="uiButtonText">打印选课名单</span></a>
								<a class="uiButton" href="<cfoutput>#buildURL('chooserDownloadExcel', targetArgs)#</cfoutput>"><i class="mrs img btnDownload"></i><span class="uiButtonText">下载电子表格</span></a>
							</div>
						</cfif>
						<h3>《<cfoutput>#rs_course.course_name#</cfoutput>》 任课单位: <cfoutput>#rs_course.institute_name#</cfoutput></h3>
						<p>
							<span class="img icon16x16 message"></span>
							该教学任务的选课人数 <em><cfoutput>#rs_chooser.recordCount#</cfoutput></em>
						</p>
					</div>
					
					<table class="UIEditable">
						<thead>
							<tr>
								<td width="30"></td>
								<td>学号</td>
								<td>姓名</td>
								<td>班级</td>
								<td width="50">年级</td>
								<td width="50">学院</td>
								<td width="60">修读方式</td>
								<td width="110">选课时间</td>
								<td width="50">学费状态</td>
							</tr>
						</thead>
						<tbody>
							<cfset row = 0 />
							<cfloop query="rs_chooser">
								<cfset row ++ />
								<cfset chooseProp.parseProperty( rs_chooser.choose_prop ) />
								<tr class="editRows">
									<td><span class="index"><cfoutput>#row#</cfoutput></span></td>
									<td><span class="numeric"><cfoutput>#rs_chooser.stu_id#</cfoutput></span></td>
									<td><cfoutput>#rs_chooser.stu_name#</cfoutput></td>
									<td><cfoutput>#rs_chooser.cls_name#</cfoutput></td>
									<td><span class="numeric"><cfoutput>#rs_chooser.grade#</cfoutput></span></td>
									<td><cfoutput>#rs_chooser.institute_short#</cfoutput></td>
									<td><cfoutput>#dictAdvice.getStudyType(rs_chooser.st)#</cfoutput></td>
									<td><span class="numeric"><cfoutput>#timeAdvice.formatDatetimeString(rs_chooser.choose_time, 'YYYY/MM/DD HH:MI')#</cfoutput></span></td>
									<td>
										<cfif chooseProp.getPrePaid()>预收
											<cfelseif chooseProp.getPaid()>已缴清
											<cfelse>未交
										</cfif>
									</td>
								</tr>
							</cfloop>
						</tbody>
					</table>
					
				</div>
			
			</div>
		</li>
	</ul>
</div>